<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ include file="/parameter.jsp"%>
<%@ include file="/pageParam.jsp" %>
<%@page isELIgnored="false"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<Meta http-equiv="Pragma" Content="No-cach" />
<title>论坛首页</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
	function loginsubmit() {
		return document.forms["form1"].submit();
	}
function SearchSubmit(){
	if(document.getElementById('keywords').value == ""){
		alert("请输入搜索关键字！");
		return false;
	}else{
		return document.forms["form3"].submit();
	}
}
</script>
	</head>

	<body>
	<jsp:include page="inc/header.jsp" />
		<header class="entry-header">
			<h1 class="entry-title">
				<span>论坛首页<div id="searchbar">
				<form name="form3" method="post" action="commonAction.do?method=SearchTopic">
					<input type="text" id="keywords" name="keywords" title="搜索"><button onClick="search();">搜索</button>
				</form>
				</div></span>
			</h1>
		</header>
		
		<div id="maindiv">
			<div id="nav">
			<c:choose>
				<c:when test="${sessionScope.user == null}">
					<div>
						<form name="form1" method="post" action="commonAction.do?method=UserLogin">
						账号：<input type="text" name="username"> 密码：<input type="password" name="password"> 
						<button onClick="loginsubmit();">登陆</button> <a href="commonAction.do?method=toRegister">注册新账号</a>
						</form>
					</div>
				</c:when>
				<c:otherwise>
					<div>
					&nbsp;&nbsp;<c:choose><c:when test="${sessionScope.user.nickname != ''}">${sessionScope.user.nickname}</c:when><c:otherwise>${sessionScope.user.username}</c:otherwise></c:choose>&nbsp;你好！<a
							href="commonAction.do?method=Logout">注销</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserInfo&uid=${sessionScope.user.id}">修改个人信息</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserPwd&uid=${sessionScope.user.id}">修改密码</a>
					</div>
				</c:otherwise>
			</c:choose>
				<a href="./" title="首页">首页</a>
				<span>&gt;</span>
                用户管理
			</div>
			<c:if test="${sessionScope.user.usergrade == '0'}">
			<div class="mngbar"><a href="commonAction.do?method=UserManagerPer">用户管理</a> | <a href="commonAction.do?method=SortPer">板块分类管理</a> | <a href="commonAction.do?method=BoardPer">板块管理</a> | <a href="commonAction.do?method=RecordPer">操作记录</a></div>
			</c:if>
			<div id="board">
				<div class="bm">
					<div class="bm_h">
						<h2>用户管理</h2>
					</div>
					<div class="bm_b">
						<form name="registerForm" id="registerForm" method="post" action="commonAction.do?method=UserManagerModifyDo" enctype="multipart/form-data" onSubmit="return Validator.Validate(this, 3)">
								<!--<div class="msg">
									<span class="message cl">&#8226;&nbsp;提示消息样式</span>
									<span class="error cl">&#8226;&nbsp;错误消息样式<span>
								</div>-->
								<div class="frm_row cl">
									<label>用户等级: </label><span>
										<select name="usergrade" onChange="">
										<option value="0" <c:if test="${user.sex == '0'}">selected</c:if>>管理员</option>
										<!--option value="1" <c:if test="${user.sex == '1'}">selected</c:if>>版主</option-->
										<option value="2" <c:if test="${user.sex == '2'}">selected</c:if>>普通用户</option>
										</select>
									</span>
								</div>
								<div class="frm_row">
									<label>用户名: </label><span>${user.username}</span>
								</div>
								<div class="frm_row">
									<label>邮件地址: </label><input type="text" name="email" value="${user.email}" style="width:300px;" title="请填写邮件地址！" datatype="Require" msg="必须填写"/>
								</div>
								<div class="frm_row">
									<label>昵称: </label><input type="text" name="nickname" value="${user.nickname}" title="请填写昵称！" datatype="Require" msg="必须填写"/>
								</div>
								<div class="frm_row cl">
									<label>性别: </label><span>
									<select name="sex" onChange="">
										<option value="保密" <c:if test="${user.sex == '保密'}">selected</c:if>>保密</option>
										<option value="帅哥" <c:if test="${user.sex == '帅哥'}">selected</c:if>>帅哥</option>
										<option value="美女" <c:if test="${user.sex == '美女'}">selected</c:if>>美女</option>
									</select>
									</span>
								</div>
								<div class="frm_row cl">
									<label>生日: </label><span>
									<select name="year" onChange="changeDate();"><!--注意:考虑到润年的关系,这里也要加上onchange事件-->
									<option value="${user.birthyear}" selected>${user.birthyear}</option>
									<%
									for(int i=1940;i<2100;i++){
									   out.print("<option value=\""+i+"\">"+i+"</option>");
									}
									%>
									</select>年
									<select name="month" onChange="changeDate();">
									<option value="${user.birthmonth}" selected>${user.birthmonth}</option>
									<%
									for(int i=1;i<13;i++){
									   out.print("<option value=\""+i+"\">"+i+"</option>");
									}
									%>
									</select>月
									<select name="day">
									<option value="${user.birthday}" selected>${user.birthday}</option>
									</select>日
									</span>
								</div>
								<!--<div class="frm_row">
									<div class="cl"><label>自定义头像: </label></div>
									<div id="pho"><input type="file" name="portrait" alt="用户上传头像！"/></div>
								</div>
								<div class="frm_row">
                                    <label>自定义头像: </label><img style="border:1px solid gray;"
                                        src="${pageContext.request.contextPath}${user.portraitpath}${user.portrait}"
                                        width="120px" height="120px" align="absMiddle">
								</div>-->
								<div class="frm_row"><input type="hidden" name="id" value="${param.id}"/>
									<button type="submit"> 保 存 </button>
								</div>
							</form>
					</div>

				</div>
			</div>
		</div>
	<jsp:include page="inc/footer.jsp" />
	</body>
<script language="javascript">
function changeDate(){
  var days = getMonthDays(document.registerForm.year.value,document.registerForm.month.value); //取得当前月应该有多少天
  var obj = document.registerForm.day;  //取得日期Select容器
  var lastValue = obj.value;  //记录用户选择的值
  if(lastValue*1 > days)lastValue = days;
  if(!lastValue)lastValue=1;
  while(obj.options.length>0) //清空日期选择框
obj.options.remove(0);
  for (var i=1; i<=days; i++)  //添加日期选项
obj.options.add(new Option(i,i));
  obj.value = lastValue;  //恢复用户选择的值
}

//获取指定月份的天数
function getMonthDays(year,month)
{
var d = new Date(year,month-1,1);
var returnValue = 0;
for(;d.getMonth()==month-1;d.setTime(d.getTime()+86400000))returnValue++;
	return returnValue;
}
changeDate(); //初始化日期选择框
</script>
</html>
